package com.lechuang.yizhezhe.view.activity.tipoff;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;


import com.lechuang.yizhezhe.R;
import com.lechuang.yizhezhe.utils.Utils;
import com.lechuang.yizhezhe.view.activity.home.SearchResultActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 作者：li on 2017/9/21 17:46
 * 邮箱：961567115@qq.com
 * 修改备注:
 */
public class TipOffFragment extends Fragment {
    @BindView(R.id.et_content)
    EditText etContent;
    @BindView(R.id.tv_search)
    TextView tvSearch;
    Unbinder unbinder;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_suofanli, container, false);
        unbinder = ButterKnife.bind(this, inflate);
        return inflate;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.tv_search)
    public void onViewClicked() {
        //搜索内容
        String search = etContent.getText().toString().trim();
        if (search == null || search.isEmpty()) {
            Utils.show(getActivity(), "搜索内容不能为空");
            return;
        }
        //判断是否包含Emoji表情
        if (Utils.containsEmoji(search)) {
            Utils.show(getActivity(), getActivity().getResources().getString(R.string.no_emoji));
            return;
        }

        Intent intent = new Intent(getActivity(), SearchResultActivity.class);
        intent.putExtra("type", 2);
        //rootName传递过去显示在搜索框上
        intent.putExtra("rootName", search);
        //rootId传递过去入参
        intent.putExtra("rootId", search);
        startActivity(intent);
    }
}
